const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter
// pages/bind_insToStu/bind_insToStu.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },


  set_addr(e){
    let value = e.detail.value
    this.setData({
      'url_data.postcode':e.detail.postcode,
      'url_data.province':value[0],
      'url_data.city':value[1],
      'url_data.area':value[2],
    })
  },

  submit(){
    wx.showModal({
      showCancel: true,
      title: '提醒',
      content:'确定要修改该学员的通讯地址吗？',
      success: res => {
        if(res.confirm){
          wx.request({
            url: domainName + '/update_stu_addr_area_submit',
            data: {
              jg_stu_id:this.data.url_data.jg_stu_id,
              postcode:this.data.url_data.postcode,
              province:this.data.url_data.province,
              city:this.data.url_data.city,
              area:this.data.url_data.area,
            },...parameter,
            success: res => {
              if(res.data.update_res){
                wx.showModal({
                  showCancel: false,
                  title: '设置完成！',
                  success: res => {
                    wx.navigateBack()
                  }
                })
              }
            },
          })
          
        }
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log('options', options)
    let url_data = JSON.parse(decodeURIComponent(options.url_data))
    this.setData({
      url_data:url_data,
    })
  },

})